package com.es.business.city;

import javax.servlet.http.HttpServletRequest;

import com.es.business.citys.CitysBiz;
import com.es.main.LoginUserBeen;
import com.es.util.common.CommonBiz;
import com.es.util.page.PageBean;
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.xwork.ActionSupport;

public class CitySearchDoAction extends ActionSupport
implements ServletRequestAware{
	 HttpServletRequest request;

	public void setServletRequest(HttpServletRequest paramHttpServletRequest) {
		// TODO Auto-generated method stub
		this.request = paramHttpServletRequest;
	}
	
	public String execute() throws Exception{
		String result = "";
		CityBiz cityBiz = new CityBiz();
		String code = this.request.getParameter("queryCityCode");
		if(code == null) code = "";
		String value = this.request.getParameter("queryCityName");
		if(value == null) value = "";
		String level = this.request.getParameter("queryCityLevel");
		if(level == null) level = "";
		String emp_area_code = this.request.getParameter("emp_area_code");
		if(emp_area_code == null) emp_area_code = "";
		String emp_province_code = this.request.getParameter("emp_province_code");
		if(emp_province_code == null) emp_province_code = "";
		String citys_code = this.request.getParameter("citys_code");
		if(citys_code == null) citys_code = "";

		String cp = this.request.getParameter("curpage");
		if(cp == null) cp = "1";
		int curpage = Integer.parseInt(cp);
		PageBean pb = cityBiz.searchCity(code, value,level,emp_province_code,citys_code, curpage);
		
		this.request.setAttribute("pageBean", pb);
		this.request.setAttribute("queryCityCode", code);
		this.request.setAttribute("queryCityName", value);
		this.request.setAttribute("queryCityLevel", level);
		this.request.setAttribute("citys_code", citys_code);
		this.request.setAttribute("emp_area_code", emp_area_code);
		this.request.setAttribute("emp_province_code", emp_province_code);
		
		CommonBiz biz = new CommonBiz((LoginUserBeen)request.getSession(false).getAttribute("loginuser"));
		 //区域列表
		   request.setAttribute("areaList", biz.getAreaList());
		   //城市群列表
		   request.setAttribute("cityslist",new CitysBiz().getCitysList());	
		   //省份列表
		   if(emp_area_code!=null)
			   request.setAttribute("provinceList", biz.getProvinceList(emp_area_code));

		result = "success";
		return result;
	}
	 

}
